﻿package com.tudou.home.controller.ad
{
    import com.tudou.ad.consts.*;
    import com.tudou.home.commands.*;
    import com.tudou.home.commands.ad.*;
    import com.tudou.home.consts.*;
    import com.tudou.home.model.*;
    import com.tudou.home.model.ad.*;
    import com.tudou.home.view.*;
    import flash.geom.*;
    import org.puremvc.as3.interfaces.*;
    import org.puremvc.as3.patterns.command.*;

    public class AdPauseCommand extends SimpleCommand
    {

        public function AdPauseCommand()
        {
            return;
        }// end function

        override public function execute(param1:INotification) : void
        {
            var _loc_6:Rectangle = null;
            var _loc_2:* = facade.retrieveProxy(AdInfoProxy.NAME) as AdInfoProxy;
            var _loc_3:* = facade.retrieveProxy(PlayerProxy.NAME) as PlayerProxy;
            var _loc_4:* = facade.retrieveMediator(SkinMediator.NAME) as SkinMediator;
            var _loc_5:* = facade.retrieveProxy(AdPauseProxy.NAME) as AdPauseProxy;
            var _loc_7:int = 0;
            switch(param1.getName())
            {
                case AdPauseCommandSet.START:
                {
                    if (_loc_5.adItemInfo)
                    {
                        _loc_5.clearAd();
                    }
                    _loc_5.adItemInfo = _loc_2.getAdItemByType(AdType.PAUSE);
                    if (_loc_5.adItemInfo != null)
                    {
                        _loc_5.adThrowInfo = _loc_2.throwInfo;
                        _loc_5.startAd();
                    }
                    break;
                }
                case AdPauseCommandSet.CLEAR:
                {
                    _loc_7 = AdModStatus.CLEAR;
                    break;
                }
                case ViewCommandSet.ENTER_FULLSCREEN_AND_RESIZE:
                {
                    _loc_6 = PlayerConsts.FULLSCREEN_RECT;
                    _loc_5.goTransform(_loc_6.width, _loc_6.height, true);
                    break;
                }
                case ViewCommandSet.NORMALSCREEN_RESIZE:
                {
                    _loc_6 = PlayerConsts.NORMALSCREEN_RECT;
                    _loc_5.goTransform(_loc_6.width, _loc_6.height, false);
                    break;
                }
                case AdPauseCommandSet.ERROR_END:
                {
                    _loc_7 = AdModStatus.ERROR_END;
                    break;
                }
                case AdPauseCommandSet.PREPARE_TO_SHOW:
                {
                    if (_loc_5 && _loc_5.view)
                    {
                        _loc_4.setAdPause(_loc_5.view.adDisplay);
                    }
                    break;
                }
                case AdPauseCommandSet.SHOW_START:
                {
                    break;
                }
                case AdPauseCommandSet.SHOW_END:
                {
                    _loc_7 = AdModStatus.CLEAR;
                    break;
                }
                default:
                {
                    break;
                    break;
                }
            }
            switch(_loc_7)
            {
                case AdModStatus.ERROR_END:
                case AdModStatus.CLEAR:
                {
                    _loc_4.removeAdPause();
                    _loc_5.clearAd();
                    break;
                }
                default:
                {
                    break;
                    break;
                }
            }
            return;
        }// end function

    }
}
